/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller.action;
 
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import model.database.SqlFolder;
import model.entities.Account;
import model.entities.Book;

/**
 *
 * @author THANH
 */
public class BookFolderAction implements Action{

    public void exe(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        HttpSession session = request.getSession();
        int folderId = Integer.parseInt(request.getParameter("sltFolder")) ;
        Book book = (Book) session.getAttribute("Book");
        Account account = (Account) session.getAttribute("Account");
        SqlFolder sqlFolder = new SqlFolder();
        int i = sqlFolder.insertBookToFolder(folderId, book.getBookId());
        account.setListFolders(sqlFolder.getListFolder(account));
        session.setAttribute("Account", account);
        request.getRequestDispatcher("Controller?Action=BookAction&Id="+book.getBookId()).forward(request, response);
        
    }
    
}
